﻿using PathologyDAL.Modle;
using System.Reflection;

namespace PathologyDAL.Service
{
    public static class AttributeValueTool
    {
        public static string GetDisplayLable<T>(string field)
        {
            var filed = typeof(T).GetField(field);
            if (filed == null)
            {
                return string.Empty;
            }
            var att = filed.GetCustomAttribute<DisplayLabelAttribute>();
            if (att == null)
            {
                return string.Empty;
            }
            return att.DisplayLable;

        }

        public static double GetStandardValue<T>(string field)
        {
            var filed = typeof(T).GetField(field);
            if (filed == null)
            {
                return 0.0;
            }
            var att = filed.GetCustomAttribute<StandardValueAttribute>();
            if (att == null)
            {
                return 0.0;
            }
            return att.StandardValue;
        }

        public static string GetNikeName<T>(string field)
        {
            var filed = typeof(T).GetField(field);
            if (filed == null)
            {
                return string.Empty;
            }
            var att = filed.GetCustomAttribute<NikeNameAttribute>();
            if (att == null)
            {
                return string.Empty;
            }
            return att.DisplayLable;

        }

    }
}
